package com.redis.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * jedis工具类
 * @Author:ChenZhangKun
 * @Date: 2020/8/2 18:59
 */
@Component
public class JedisUtils {
    @Autowired
    private JedisPool jedisPool;
    // 得到jedis
    public Jedis getJedis(){
        return jedisPool.getResource();
    }
    // 释放jedis
    public void close(Jedis jedis){
        if (jedis!=null){
            jedis.close();
        }
    }

}
